<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../../Css/style.css" />
	<script type="text/javascript" src="../../Js/jquery-2.1.4.min.js"></script>
    <script type="text/javascript" src="../../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../../Js/ckform.js"></script>
    <script type="text/javascript" src="../../Js/common.js"></script>

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
    <script>
    /*加载商品信息  */
        $(document).ready(function(){
			$.ajax({
				type:"post",
				url:"../../commdidties/findcommodities",
				contentType:"application/json;charset=utf-8",
				success:function(commodities){
					$('tbody').html("");
					for(var i=0;i<commodities.length;i++ ){
						$('tbody')
				  		.append("<tr id=1>"+
				  				"<td>"+commodities[i].claname+"</td>"+
				  				"<td>"+commodities[i].coid+"</td>"+
				  				"<td>"+commodities[i].coname+"</td>"+
				  				"<td>"+commodities[i].cophoto+"</td>"+
				  				"<td>"+commodities[i].conum+"</td>"+
				  				"<td>"+commodities[i].coprice+"</td>"+
				  				"<td>"+commodities[i].uid+"</td>"+
				  				"<td>"+"<a href=edit.html?coid="+commodities[i].coid+">编辑</a>"+"</td>"+ 
				  				"</tr>");
						//$('#pagenum').html("1 条记录 1/1页");
					}
				}
			}
					);  
   }); 
    /*下拉连动列表  */
   $(document).ready(function(){
			$.ajax({
				type:"post",
				url:"../../commdidties/findcoclass",
				contentType:"application/json;charset=utf-8",
				success:function(coclass){
					$('#coclass').html("");
					$('#coclass').append("<option value=-->--</option>");
					for(var i=0;i<coclass.length;i++ ){
						$('#coclass')
							.append("<option value="+coclass[i].claname+">"+coclass[i].claname+"</option>");
					}
				}
			}
					);  
   });
	$(function(){
		$('#coclass').click(function(){
			var claname = $('#coclass').val();
			 $('#coname').html("");
				$('#coname').append("<option value=-->--</option>");
			//alert(claname);
			$.ajax({
				type:"post",
				url:"../../commdidties/findconame?claname="+claname,
				contentType:"application/json;charset=utf-8",
				success:function(commoditiesVo){
					//alert(commoditiesVo);
					
				 	for(var i=0;i<commoditiesVo.length;i++ ){
						$('#coname')
							.append("<option value="+commoditiesVo[i].coname+">"+commoditiesVo[i].coname+"</option>");
					} 
				}
					});
			//$('#coname option').html(claname);
		});
	});
	/*查询点击事件  */
	$(function(){
		$('#btn-query').click(function(){
			var coclass = $('#coclass').val();
			var coname = $('#coname').val();
			var commoditiesid = $('#commoditiesid').val();
			alert(coclass+"xxx"+coname+"ccc"+commoditiesid);
			if(coclass == "--"){
				if(coname == "--"){
					if(commoditiesid == ""){
						//alert('全部显示');
						/*start 1*/
						$.ajax({
				type:"post",
				url:"../../commdidties/findcommodities",
				contentType:"application/json;charset=utf-8",
				success:function(commodities){
					$('tbody').html("");
					for(var i=0;i<commodities.length;i++ ){
						$('tbody')
				  		.append("<tr id=1>"+
				  				"<td>"+commodities[i].claname+"</td>"+
				  				"<td>"+commodities[i].coid+"</td>"+
				  				"<td>"+commodities[i].coname+"</td>"+
				  				"<td>"+commodities[i].cophoto+"</td>"+
				  				"<td>"+commodities[i].conum+"</td>"+
				  				"<td>"+commodities[i].coprice+"</td>"+
				  				"<td>"+commodities[i].uid+"</td>"+
				  				"<td>"+"<a href=edit.html?coid="+commodities[i].coid+">编辑</a>"+"</td>"+ 
				  				"</tr>");
						//$('#pagenum').html("1 条记录 1/1页");
					}
				}
			}
					);  
						/*end 1*/
					}else{
						//alert('按商品id查询');
						/*start 2*/
						$.ajax({
							type:"post",
							url:"../../commdidties/findcoid?coid="+commoditiesid,
							contentType:"application/json;charset=utf-8",
							success:function(commodities){
								$('tbody').html("");
								for(var i=0;i<commodities.length;i++ ){
									$('tbody')
							  		.append("<tr id=1>"+
							  				"<td>"+commodities[i].claname+"</td>"+
							  				"<td>"+commodities[i].coid+"</td>"+
							  				"<td>"+commodities[i].coname+"</td>"+
							  				"<td>"+commodities[i].cophoto+"</td>"+
							  				"<td>"+commodities[i].conum+"</td>"+
							  				"<td>"+commodities[i].coprice+"</td>"+
							  				"<td>"+commodities[i].uid+"</td>"+
							  				"<td>"+"<a href=edit.html?coid="+commodities[i].coid+">编辑</a>"+"</td>"+ 
							  				"</tr>");
									//$('#pagenum').html("1 条记录 1/1页");
								}
							}
								});
						/*end 2*/
					}
				}else{
					if(commoditiesid == ""){
						//alert('按商品名称查询');
						/*start 3*/
						$.ajax({
							type:"post",
							url:"../../commdidties/findbyconame?coname="+coname,
							contentType:"application/json;charset=utf-8",
							success:function(commodities){
								$('tbody').html("");
								for(var i=0;i<commodities.length;i++ ){
									$('tbody')
							  		.append("<tr id=1>"+
							  				"<td>"+commodities[i].claname+"</td>"+
							  				"<td>"+commodities[i].coid+"</td>"+
							  				"<td>"+commodities[i].coname+"</td>"+
							  				"<td>"+commodities[i].cophoto+"</td>"+
							  				"<td>"+commodities[i].conum+"</td>"+
							  				"<td>"+commodities[i].coprice+"</td>"+
							  				"<td>"+commodities[i].uid+"</td>"+
							  				"<td>"+"<a href=edit.html?coid="+commodities[i].coid+">编辑</a>"+"</td>"+ 
							  				"</tr>");
									//$('#pagenum').html("1 条记录 1/1页");
								}
							}
								});
						/*end 3*/
					}else{
						//alert('按商品id查询');
						/*start 4*/
						$.ajax({
							type:"post",
							url:"../../commdidties/findcoid?coid="+commoditiesid,
							contentType:"application/json;charset=utf-8",
							success:function(commodities){
								$('tbody').html("");
								for(var i=0;i<commodities.length;i++ ){
									$('tbody')
							  		.append("<tr id=1>"+
							  				"<td>"+commodities[i].claname+"</td>"+
							  				"<td>"+commodities[i].coid+"</td>"+
							  				"<td>"+commodities[i].coname+"</td>"+
							  				"<td>"+commodities[i].cophoto+"</td>"+
							  				"<td>"+commodities[i].conum+"</td>"+
							  				"<td>"+commodities[i].coprice+"</td>"+
							  				"<td>"+commodities[i].uid+"</td>"+
							  				"<td>"+"<a href=edit.html?coid="+commodities[i].coid+">编辑</a>"+"</td>"+ 
							  				"</tr>");
									//$('#pagenum').html("1 条记录 1/1页");
								}
							}
								});
						/*end 4*/
					}
				}
			}else{
				if(coname == "--" && commoditiesid == ""){
					//alert('按商品类型查询');
					/*start 5*/
					$.ajax({
						type:"post",
						url:"../../commdidties/findconame?claname="+coclass,
						contentType:"application/json;charset=utf-8",
						success:function(commoditiesVo){
							$('tbody').html("");
							for(var i=0;i<commoditiesVo.length;i++ ){
								$('tbody')
						  		.append("<tr id=1>"+
						  				"<td>"+commoditiesVo[i].claname+"</td>"+
						  				"<td>"+commoditiesVo[i].coid+"</td>"+
						  				"<td>"+commoditiesVo[i].coname+"</td>"+
						  				"<td>"+commoditiesVo[i].cophoto+"</td>"+
						  				"<td>"+commoditiesVo[i].conum+"</td>"+
						  				"<td>"+commoditiesVo[i].coprice+"</td>"+
						  				"<td>"+commoditiesVo[i].uid+"</td>"+
						  				"<td>"+"<a href=edit.html?coid="+commoditiesVo[i].coid+">编辑</a>"+"</td>"+ 
						  				"</tr>");
								//$('#pagenum').html("1 条记录 1/1页");
							}
						}
							});
					/*end 5*/
				}else{
					if(commoditiesid == ""){
						//alert('按商品名称查询');
						/*start 6*/
						$.ajax({
							type:"post",
							url:"../../commdidties/findbyconame?coname="+coname,
							contentType:"application/json;charset=utf-8",
							success:function(commodities){
								$('tbody').html("");
								for(var i=0;i<commodities.length;i++ ){
									$('tbody')
							  		.append("<tr id=1>"+
							  				"<td>"+commodities[i].claname+"</td>"+
							  				"<td>"+commodities[i].coid+"</td>"+
							  				"<td>"+commodities[i].coname+"</td>"+
							  				"<td>"+commodities[i].cophoto+"</td>"+
							  				"<td>"+commodities[i].conum+"</td>"+
							  				"<td>"+commodities[i].coprice+"</td>"+
							  				"<td>"+commodities[i].uid+"</td>"+
							  				"<td>"+"<a href=edit.html?coid="+commodities[i].coid+">编辑</a>"+"</td>"+ 
							  				"</tr>");
									//$('#pagenum').html("1 条记录 1/1页");
								}
							}
								});
						/*end 6*/
					}else{
						//alert('按商品id查询');
						/*start 7*/
						$.ajax({
							type:"post",
							url:"../../commdidties/findcoid?coid="+commoditiesid,
							contentType:"application/json;charset=utf-8",
							success:function(commodities){
								$('tbody').html("");
								for(var i=0;i<commodities.length;i++ ){
									$('tbody')
							  		.append("<tr id=1>"+
							  				"<td>"+commodities[i].claname+"</td>"+
							  				"<td>"+commodities[i].coid+"</td>"+
							  				"<td>"+commodities[i].coname+"</td>"+
							  				"<td>"+commodities[i].cophoto+"</td>"+
							  				"<td>"+commodities[i].conum+"</td>"+
							  				"<td>"+commodities[i].coprice+"</td>"+
							  				"<td>"+commodities[i].uid+"</td>"+
							  				"<td>"+"<a href=edit.html?coid="+commodities[i].coid+">编辑</a>"+"</td>"+ 
							  				"</tr>");
									//$('#pagenum').html("1 条记录 1/1页");
								}
							}
								});
						/*end 7*/
					}
				}	
			}
		});
	});
	/*清空点击事件  */
	$(function(){
		$('#btn-clear').click(function(){
			//$('#coclass').html('').append("<option value='--'>--</option>");
			$.ajax({
				type:"post",
				url:"../../commdidties/findcoclass",
				contentType:"application/json;charset=utf-8",
				success:function(coclass){
					$('#coclass').html("");
					$('#coclass').append("<option value=-->--</option>");
					for(var i=0;i<coclass.length;i++ ){
						$('#coclass')
							.append("<option value="+coclass[i].claname+">"+coclass[i].claname+"</option>");
					}
				}
			}
					);  
			$('#coname').html('').append("<option value='--'>--</option>");
			$('#commoditiesid').html('');
		});
	});
	/*添加点击事件  */
	$(function(){
		$('#btn-add').click(function(){
			window.location.href="add.html";
		});
	});
</script>
</head>
<body>
<div class="form-inline definewidth m20">
    商品检索 &nbsp;&nbsp;&nbsp;&nbsp;
   类型：<select id="coclass" style="width:100px;">
  <option value="--">--
   </option>
   </select>
   商品名：<select id="coname" style="width:100px;">
   <option value="--">--
   </option>
   </select>
    商品号：<input type="text" name="commoditiesid" id="commoditiesid" class="abc input-default" placeholder="" value="">&nbsp;&nbsp; 
    <button type="button" class="btn btn-primary" id="btn-query">查询</button>
    <button type="button" class="btn btn-primary" id="btn-clear">清空</button>
    <button type="button" class="btn btn-primary" id="btn-add">添加</button>
</div>
<table class="table table-bordered table-hover definewidth m10">
    <thead>
    <tr>
     	<th>类型：</th>
        <th>商品号：</th>
        <th>商品名：</th>
        <th>样式：</th>
        <th>数量：</th>
        <th>价格(￥)：</th>
        <th>归属：</th>
        <th>编辑：</th>
    </tr>
    </thead>
	    <tbody></tbody>
     </table>
</body>
</html>
